﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using ERP_RORZE_DLL.Product.DAO;
using ERP_RORZE_PERMISSION.Base;
using Utilities = ERP_RORZE_TOOL.Common.Utilities;

namespace ERP_RORZE_PRODUCT.Product.WTS
{
    public partial class frm_MachineWTStoGA : DevExpress.XtraEditors.XtraForm
    {
        ClsWTSDAO clsWTSDAO = new ClsWTSDAO();

        private LogUtils log;
        DataTable dt;

        public frm_MachineWTStoGA()
        {
            InitializeComponent();
            log = new LogUtils();
        }

        private void btnRefresh_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            dt = clsWTSDAO.GetAllMachineWTStoGA(dateFrom.Value,dateTo.Value);
            gridControl1.DataSource = dt;
            gridView1.PopulateColumns();
            gridView1.BestFitColumns();

            //write Log
            log.Table = LogConstant.Table.Product.WTStoGAMachine;
            log.Task = LogConstant.Task.View;
            log.Description = "View WTStoGA Machine from " + dateFrom.Value.Date.ToShortDateString() + " to " + dateTo.Value.Date.ToShortDateString();
            log.WriteLog();

            Cursor.Current = Cursors.Default;
        }

        private void btExport_Click(object sender, EventArgs e)
        {
            Utilities.ExportToExcel(gridView1, 1, true);
        }

        private void btCheckCode_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            dt = clsWTSDAO.GetAllWTStoGACheckCode(dateFrom.Value, dateTo.Value);
            gridControl1.DataSource = dt;
            gridView1.PopulateColumns();
            gridView1.BestFitColumns();
            Cursor.Current = Cursors.Default;
        }
    }
}